<?
include('../scaffold/comment.php');
include('../scaffold/content.php');
include('../scaffold/tag.php');
include('../controller/handler.php');
include('../controller/philomousia.php');

include('../module/var.inc.php');

session_start();

$hd = new Handler();
$ph = new Philomousia();
$base_url = $hd->getBaseURL();
$hd->openDB();
$contents = $ph->loadContentsByDate($_GET['year'], $_GET['month'], $_GET['day'], $hd);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="it" lang="it">
<head>
	<? include('../module/head.inc.php'); ?>
	<script src="<?echo $base_url;?>js/editor.js" type="text/javascript" charset="utf-8"></script>
</head>

<body>
<div id="archive"></div>
<div id="content">
<?include('../module/header.inc.php');?>

<?
foreach($contents as $content) {
?>
<div class="article">
	<div class="upper_bar_main"><div class="upper_bar_round"></div></div>
	<div class="body_main_left">
	<div class="body_main_right">
	<div class="body_main">
	<h2><?echo $content->getTitle();?></h2>
	<div class="body">
		<div class="small date"> 
			<div class="month"><?echo strftime("%b", strtotime($content->getDate()));?></div> 
			<div class="day"><?echo strftime("%e", strtotime($content->getDate()));?></div> 
			<div class="year"><?echo strftime("%Y", strtotime($content->getDate()));?></div> 
		</div>
		<?echo $hd->makeHTML($content->getBody());?> &loz;
		<p class="author"><?echo $content->getAuthor();?></p>
	</div>
	
	<p class="small tags">
		Archiviato in <a href="<?echo $base_url.$links[$content->getType()];?>">
			<?echo $section[$content->getType()];?></a> |
		Articoli simili in 
		<?foreach($content->getTags() as $key => $value) {?>
			<!--<a href="<?echo $base_url.$this_page."tag:".$value->getId();?>"><?echo $value->getName();?></a> -->
			<a href="<?echo $base_url."tag:".$value->getId();?>"><?echo $value->getName();?></a> 
		<?}?>
		<?if($hd->allowComments()) {?>
		|
		<?if(!isset($_GET['id'])) {?>
		<a href="<?echo $base_url.$links[$content->getType()];?>/post:<?echo $content->getId();?>">
			<?php echo $ph->getCommentsNumber($hd, $content->getId()) ?> commenti</a>
		<?} else {?>
			<?echo count($comments);?> commenti | 
			<span class="pseudo_link" onclick="new Effect.toggle('comment_form', 'blind')">Inserisci commento</span>
		<?}?>
		<?}?>
	</p>
	
	<?if($hd->getPassword()==sha1($_SESSION['password'])) {?>
	<p class="small admin_action">
		<a href="<?echo $base_url;?>panel">Pannello di amministrazione</a> |
		<a href="<?echo $base_url;?>panel/manage:<?echo $content->getId();?>">Gestisci articolo</a>
	</p>
	<?}?>
	</div></div></div>
	<div class="lower_bar_main"><div class="lower_bar_round"></div></div>
</div>
<?}?>

<div id="page">
<div class="upper_bar_main"><div class="upper_bar_round"></div></div>
<div class="body_main_left">
<div class="body_main_right">
<div class="body_main">
	<div id="page_body">{ <? echo count($contents); ?> articoli }</div>
</div></div></div>
<div class="lower_bar_main"><div class="lower_bar_round"></div></div>
</div>

<?if($hd->allowComments() && $display_comment) { 
	include('../module/comment.inc.php');
}?>

<? include('../module/footer.inc.php'); ?>
</div>
<? include('../module/analytics.inc.php'); ?>
</body>
</html>

<?$hd->closeDB();?>